package com.guosong.rabbitmq.workqueue;

import com.google.gson.Gson;
import com.guosong.rabbitmq.utils.RabbitConstant;
import com.guosong.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class OrderSystem {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getConnection();
        Channel channel = connection.createChannel();
        AMQP.Queue.DeclareOk declareOk = channel.queueDeclare(RabbitConstant.QUEUE_SMS, false, false, false, null);
        for (int i=0;i<100;i++){
            SMS sms = new SMS("乘客" + i, "13900000" + i, "您的车票已预订成功");
            String jsonSMs = new Gson().toJson(sms);
            channel.basicPublish("",RabbitConstant.QUEUE_SMS,null,jsonSMs.getBytes());
        }
        System.out.println("发送数据成功");
        channel.close();
        connection.close();

    }

}
